package com.ca.ridersclubapplication.request;

import android.app.Activity;

import com.ca.ridersclubapplication.data.DataHandler;
import com.ca.ridersclubapplication.data.entity.Token;
import com.ca.ridersclubapplication.request.dto.Result;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;
import retrofit2.http.Query;

public class CaptchaRequester {

    public static final String URL = "captcha/";

    public static final CaptchaAPI api;

    static {
        api = new Retrofit.Builder()
                .baseUrl(Config.BASE_URL + URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(CaptchaAPI.class);
    }

    public interface CaptchaAPI {

        @GET("send")
        Call<Result<String>> sendCaptcha(
                @Query("email") String email,
                @Query("purposes") String purposes);
    }

    public static void sendCaptcha(Activity activity, String email, String purposes, AfterExecutor<String> executor) {
        api.sendCaptcha(email, purposes).enqueue(new APICallback<>(activity, executor));
    }
}
